package com.kksoft.readcm.activity;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.kksoft.readcm.a.Appconfig;
import com.kksoft.readcm.objects.ErrorReport;
import com.kksoft.readcm.objects.m;
import com.kksoft.readcm.pro.R;

import java.net.URLEncoder;

public class HelpActivity extends RilAppActivity
{
	
	static void a(HelpActivity helpactivity, int i)
    {
        a(i, ((Context) (helpactivity)));
    }

  public static void a(int paramInt, Context paramContext)
  {
    switch (paramInt)
    {
    case 1:
    	a("file:///android_asset/help/getting_started.html", true, paramContext);
    	break;
    case 2:
    	a("file:///android_asset/help/add/add.html", true, paramContext);
    	break;
    case 3:
    	a("file:///android_asset/help/downloading.html", true, paramContext);
    	break;
    case 4:
    	a("http://readitlaterlist.com/android/syncing", false, paramContext);
    	break;
    case 5:
    	a("file:///android_asset/help/tips.html", true, paramContext);
    	break;
    case 6:
    	a("file:///android_asset/help/tagging.html", true, paramContext);
    	break;
    case 7:
    	a("http://readitlaterlist.com/support/", false, paramContext);
    	break;
    case 8:
    	a("http://www.ideashower.com/support/read-it-later/", false, paramContext);
    	break;
    case 9:
    	a("file:///android_asset/help/positions.html", true, paramContext);
    	break;
    case 10:
    	a("http://readitlaterlist.com/credits", false, paramContext);
    	break;
    default:
    	break;
    }
  }

  public static void a(int paramInt, ErrorReport paramErrorReport, Context paramContext)
  {
//	  String str1;
//	  switch (paramInt)
//	  {
//	  	case 1:
//	  		str1 = "Android App Sync Error";
//	  		break;
//	  	case 2:
//	  		str1 = "Android App Login Error";
//	  		break;
//	  	case 3:
//	  		str1 = "Android App Database Error";
//	  		break;
//		default:
//			str1 = "Android App Error";
//			break;
//	  }
//	  
//      Object[] arrayOfObject1 = new Object[2];
//      String str2 = App.e().e();
//      arrayOfObject1[0] = str2;
//      String str3 = m.f();
//      arrayOfObject1[1] = str3;
//      String str4 = String.format("Read It Later %s %s", arrayOfObject1);
//      Object[] arrayOfObject2 = new Object[1];
//      arrayOfObject2[0] = str4;
//      String str5 = String.valueOf(String.format("I am having a problem with %s for Android.", arrayOfObject2));
//      String str6 = String.valueOf(str5 + "\n");
//      String str7 = String.valueOf(str6 + "\n---\n\n");
//      String str8 = String.valueOf(str7 + "Here is some additional information about the problem\n");
//      String str9 = String.valueOf(str8 + "\n");
//      String str10 = String.valueOf(str9 + "App: " + str4 + "\n");
//      StringBuilder localStringBuilder1 = new StringBuilder(str10).append("Device: ");
//      String str11 = Build.MANUFACTURER;
//      StringBuilder localStringBuilder2 = localStringBuilder1.append(str11).append(" ");
//      String str12 = Build.MODEL;
//      String str13 = String.valueOf(str12 + "\n");
//      StringBuilder localStringBuilder3 = new StringBuilder(str13).append("Android: ");
//      int i = Build.VERSION.SDK_INT;
//      String str14 = i + "\n";
//      if (paramErrorReport != null)
//      {
//        String str15 = String.valueOf(str14);
//        StringBuilder localStringBuilder4 = new StringBuilder(str15).append("Error Message: ");
//        String str16 = paramErrorReport.b();
//        String str17 = String.valueOf(str16 + "\n");
//        StringBuilder localStringBuilder5 = new StringBuilder(str17).append("Details: ");
//        String str18 = paramErrorReport.a();
//        String str19 = String.valueOf(str18 + "\n");
//        StringBuilder localStringBuilder6 = new StringBuilder(str19).append("Screen: ");
//        String str20 = paramErrorReport.c();
//        str14 = str20;
//      }
//      String str21 = URLEncoder.encode(str1);
//      String str22 = URLEncoder.encode(str14);
//      Object[] arrayOfObject3 = new Object[2];
//      arrayOfObject3[0] = str21;
//      arrayOfObject3[1] = str22;
//      Uri localUri = Uri.parse(String.format("http://support.readitlaterlist.com/discussion/new?discussion[title]=%s&discussion[body]=%s", arrayOfObject3));
//      Intent localIntent1 = new Intent("android.intent.action.VIEW", localUri);
//      localIntent1.addFlags(524288);
//      paramContext.startActivity(localIntent1);
  }

  private static void a(String s1, boolean flag, Context context)
  {
      if(flag)
      {
          Intent intent = new Intent(context, BasicWebViewActivity.class);
          intent.putExtra("pathToLoad", s1);
          context.startActivity(intent);
      } else
      {
          Uri uri = Uri.parse(s1);
          Intent intent2 = new Intent("android.intent.action.VIEW", uri);
          intent2.addFlags(0x80000);
          context.startActivity(intent2);
      }
  }

  public void onCreate(Bundle bundle)
  {
//    this.t = 1;
    super.onCreate(bundle);
    Button btnStart = (Button)findViewById(R.id.help_getting_started);
    btnStart.setOnClickListener(new OnClickListener(){ 
		public void onClick(View arg0) {
			HelpActivity.a(HelpActivity.this,1);
        }
	});
    
    Button btnAdding = (Button)findViewById(R.id.help_adding);
    btnAdding.setOnClickListener(new OnClickListener(){ 
		public void onClick(View arg0) {
			HelpActivity.a(HelpActivity.this,2);
        }
	});
    
    Button btnDowning = (Button)findViewById(R.id.help_downloading);
    btnDowning.setOnClickListener(new OnClickListener(){ 
		public void onClick(View arg0) {
			HelpActivity.a(HelpActivity.this,3);
        }
	});
    
    Button btnSyncing = (Button)findViewById(R.id.help_syncing);
    btnSyncing.setOnClickListener(new OnClickListener(){ 
		public void onClick(View arg0) {
			HelpActivity.a(HelpActivity.this,4);
        }
	});
    
    Button btnTips = (Button)findViewById(R.id.help_tips);
    btnTips.setOnClickListener(new OnClickListener(){ 
		public void onClick(View arg0) {
			HelpActivity.a(HelpActivity.this,5);
        }
	});
    
    Button btnTag = (Button)findViewById(R.id.help_tagging);
    btnTag.setOnClickListener(new OnClickListener(){ 
		public void onClick(View arg0) {
			HelpActivity.a(HelpActivity.this,6);
        }
	});
    
    Button btnAsk = (Button)findViewById(R.id.help_ask_question);
    btnAsk.setOnClickListener(new OnClickListener(){ 
		public void onClick(View arg0) {
			HelpActivity.a(HelpActivity.this,7);
        }
	});
    
    Button btnSug = (Button)findViewById(R.id.help_suggestion);
    btnSug.setOnClickListener(new OnClickListener(){ 
		public void onClick(View arg0) {
			HelpActivity.a(HelpActivity.this,8);
        }
	});
  }

  public boolean onPrepareOptionsMenu(Menu menu)
  {
	  boolean flag;
      if(Appconfig.getThis().isLogined())
      {
          flag = super.onPrepareOptionsMenu(menu);
      } else
      {
          menu.setGroupVisible(-1, false);
          menu.setGroupVisible(-1, false);
          menu.setGroupVisible(-1, false);
          flag = true;
      }
      return flag;
  }

  protected final int getLayoutID()
  {
    return R.layout.activity_help;
  }
}